package com.atguigu.gulimall.ware.dao;

import com.atguigu.gulimall.ware.entity.HasStock;
import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author guokefa
 * @email guokefa@gmail.com
 * @date 2022-02-10 11:51:58
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    /**
     * 添加入库信息
     * @param skuId
     * @param wareId
     * @param skuNum
     */
    void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

    Long getSkuStock(@Param("skuId") Long skuId);

    void stockDecrease(@Param("skuId") Long skuId);

    List<HasStock> getSkuStockByIds(@Param("skuIds") List<Long> skuIds);

    Long lockSkuStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);

    List<Long> listWareIdHasSkuStock(@Param("skuId") Long skuId);
}
